<template>
  <div class="contact-configuration common-content-style">
  	<h3>联系配置</h3>
    <div class="editor-container">
      <UE :defaultMsg=defaultMsg :config=config ref="ue"></UE>
    </div>
    <p class="btn">
    	<button class="Public-btn" @click="save()">保存</button>
    </p> 
  </div>
</template>
<script>
	import UE from "../shareComponent/UE";
	export default {
    name:'contact-configuration',
    data: function(){
      return{
        defaultMsg: "",
        config: {
          initialFrameWidth: null,
          initialFrameHeight: 350
        },
        /*当前id*/
        id:-1
      }
    },
    mounted:function(){
    	this.queryQuestionByType();
    },
    components:{UE},
    methods:{
    	getUEContent() {
        let content = this.$refs.ue.getUEContent();
        this.$router.push({path:"/main/questionBank"});
        
      },
      /*获取联系方式*/
    	queryQuestionByType:function(){
    		this.$post(
          '/qa/queryQuestionByType',
          {
          	"type":"",
          	"istop":"0",
            "status":"3",
            "page":"1",
            "size":"10",
          }).then(response => {
          if (response.resultCode == "0") {
          	this.defaultMsg=response.resultData.qaInfoList[0].answer;
          	this.id=response.resultData.qaInfoList[0].id;
          }else{
          	layer.alert(response.resultMsg);
          }
        }).catch(err => {
          console.log(err)
        })
    	},
    	/*保存*/
    	save:function(){
    		let content = this.$refs.ue.getUEContent();
    		if(!content){
    			layer.alert("请填写联系配置");
    			return;
    		}
    		this.$post(
          '/qa/addQuestion',
          {
            "id":this.id,
            "answer":content,
          }).then(response => {
          if (response.resultCode == "0") {
          	this.$router.push({path:"/main/questionBank"});
          }else{
          	layer.alert(response.resultMsg);
          }
        }).catch(err => {
          console.log(err)
        })
    	}
    }
	}
</script>
<style lang="less" scoped>
	.contact-configuration{
		
	}
</style>
